package com.example.springboot_template.common;

import java.io.Serializable;

/**
 * 通用返回类
 * @param <T>
 */
public class BaseResponse<T> implements Serializable {
    private final int code;
    private final T data;
    private final String message;
    private final String description;

    public BaseResponse(int code, T data, String message,String description) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description = description;
    }
    public BaseResponse(int code , T data,String message){
        this(code,data,message,"");
    }
    public BaseResponse(int code , T data){
        this(code,data,"","");
    }

    public BaseResponse(ErrorCode errorCode){
        this(errorCode.getCode(),null, errorCode.getMessage(),errorCode.getDescription());
    }

    public int getCode() {
        return code;
    }

    public T getData() {
        return data;
    }

    public String getMessage() {
        return message;
    }

    public String getDescription() {
        return description;
    }
}
